#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e5;
const int M = 1e6;
double d[N + 5],v[N + 5];
int p[N + 5],t,dp[N + 5];
double a[N + 5];
int num[M + 5],s[N + 5];
signed main(){
	freopen ("detect.in","r",stdin);
	freopen ("detect.out","w",stdout);
	cin >> t;
	while (t --){
		memset (num,0,sizeof num);
		int n,m,l,V;
		int ans = 0,flag = 0;
		cin >> n >> m >> l >> V;
		for (int i = 1;i <= n;i ++) cin >> d[i] >> v[i] >> a[i];
		for (int i = 1;i <= m;i ++) cin >> p[i];
		for (int i = 1;i <= n;i ++){
			if (a[i] > 0){
				double tim = (V * V - v[i] * v[i]) * 1.0 / (2 * a[i]);
				if (tim + d[i] <= p[m]){
					ans ++;
					for (int j = m;j >= 1;j --){
						if (p[j] < tim + d[i]){
							break;
						}
						num[p[j]] ++;
					}
				}
			}
			if (a[i] == 0){
				if (v[i] > V){
					for (int j = 1;j <= m;j ++) num[p[j]] ++;
					ans ++;
				}
			}
			if (a[i] < 0){
				double tim = (V * V - v[i] * v[i]) * 1.0 / (2 * a[i]);
				for (int j = 1;j <= m;j ++){
					if (p[j] >= d[i] && p[j] <= d[i] + tim){
						num[p[j]] ++;
						flag = 1;
					}
					if (p[j] > d[i] + tim) break;
				}
			} 
			ans += flag;
			flag = 0;
		}
		memset (dp,0x3f,sizeof dp);
		dp[num[1]] = 0;
		for (int i = 2;i <= l;i ++){
			for (int j = n;j >= num[i];j --)
				dp[j] = min (dp[j],dp[j - num[i]] + 1);
		}
		cout << ans << " " << n - dp[l] << endl;
	}
	return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15

1
9 10 110373 907
34507 939 -1
5901 998 -1
66753 982 -3
8013 970 -8
62012 959 -5
68954 984 -2
15403 987 -1
6321 991 -5
15081 981 -1
2491 7419 8047 15204 15495 36392 62765 69004 81638 90563
*/
